var mongoose=require("mongoose");
var db=require("./db");

var kechengSchema=new mongoose.Schema({
    kid:Number,
    name:String,
    students:[Number]
})

kechengSchema.statics.tianjiaxuesheng=function(arr,sid,cb){
    if (arr.length==0) {
        return
    }
    for(var i=0;i<arr.length;i++){
        Kecheng.update({kid:arr[i]},{$push:{"students":sid}},function(){
            console.log("添加成功")
        })
    }
}

kechengSchema.index({sid:1});

var Kecheng=db.model("Kecheng",kechengSchema);

module.exports=Kecheng;